"""
File: service.py
Author: ershixiong
Date: 2024/3/22
describe:

"""
import json

import requests
from jsonpath import jsonpath

from ddt_framework_02.utils import logger


class Service:
    _BASE_URL = 'https://spring-petclinic-rest.k8s.hogwarts.ceshiren.com/petclinic/api/'

    def __init__(self):
        self.r = None

    def send_request(self, value):
        value['url'] = f"{self._BASE_URL}{value.get('url')}"

        self.r = requests.request(**value).text
        logger.debug(self.r)


    def get_r(self):
        return self.r

    def run_step(self, step):
        for key, value in step.items():
            if key == 'request':
                self.send_request(value)
            elif key == '断言':
                assert eval(value)
            #
            # if key == 'get':
            #     self.get(value)
            # elif key == 'post':
            #     self.post(value)
            # elif key == 'put':
            #     self.put(value)
            # elif key == 'delete':
            #     self.delete(value)
            # elif key == '断言':
            #     assert eval(value)


service: Service = None
